package com.UdpRecieve.framework.listenner;


import com.UdpRecieve.framework.constant.ServletConstant;
import com.UdpRecieve.framework.utils.ServletUtils;
import com.UdpRecieve.tool.CookieUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class SysServletContextListener implements ServletContextListener {

    private Logger logger = LoggerFactory.getLogger(SysServletContextListener.class);

    @Override
    public void contextDestroyed(ServletContextEvent contextEvent) {
        // TODO Auto-generated method stub
        logger.info("servlet销毁");
        //清楚cookie
        CookieUtils.deleteCookie(ServletUtils.getRequest(),ServletUtils.getResponse(), ServletConstant.WEB_TOKEN);
    }

    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        // TODO Auto-generated method stub
        logger.info("servlet初始化");
    }
}
